package com.ruoyi.framework.web.service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.Address;
import com.ruoyi.common.utils.ip.AddressUtils;
import com.ruoyi.pay.domain.PayCoinUserForm;
import com.ruoyi.pay.service.IPayCoinUserService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.wq.domain.WqComment;
import com.ruoyi.wq.domain.WqDynamic;
import com.ruoyi.wq.domain.WqDynamicTopic;
import com.ruoyi.wq.domain.WqTopic;
import com.ruoyi.wq.service.IWqCommentService;
import com.ruoyi.wq.service.IWqDynamicService;
import com.ruoyi.wq.service.IWqDynamicTopicService;
import com.ruoyi.wq.service.IWqTopicService;
import com.ruoyi.wx.domain.WxMaForm;
import com.ruoyi.wx.domain.WxMaMsgForm;
import com.ruoyi.wx.domain.WxMpMsgForm;
import com.ruoyi.wx.service.WxMaCodeService;
import com.ruoyi.wx.service.WxMsgService;

import cn.hutool.core.date.DateUtil;

@Component
public class DynamicService {
	
	@Autowired
	private ISysUserService sysUserService;
	
	@Autowired
	private IWqDynamicService wqDynamicService;
	
	@Autowired
	private IWqTopicService wqTopicService;
	
	@Autowired
	private IWqDynamicTopicService wqDynamicTopicService;
	
	@Autowired
    private IPayCoinUserService payCoinUserService;
	
	@Autowired
	private IWqCommentService wqCommentService;
	
	@Autowired
	private WxMaCodeService wxMaCodeService;
	
	@Autowired
    private WxMsgService wxMsgService;
	
	@Autowired
    private Executor threadPoolTaskExecutor;
	
	@Autowired
	private QunService qunService;
	
	@Autowired
	private RedisCache redisCache;
    
    public final static String KEY_DYNAMIC = "key:dynamic:";
    public final static String KEY_DYNAMIC_TOTAL = "key:dynamic:total:";

	public synchronized Boolean saveDynamic(WqDynamic wqDynamic) {
		String topicIds = wqDynamic.getTopicIds();
		SysUser user = sysUserService.getById(wqDynamic.getUserId());
		if(StringUtils.isBlank(user.getSex())){
			throw new ServiceException("请在个人主页完善性别信息");
		}
		
		WqTopic topic = null;
		if(StringUtils.isNotBlank(topicIds)){
			String[] topicIdList = topicIds.split(",");
			if(topicIdList.length > 1){
				throw new ServiceException("最多只能选择一个话题");
			}
			
			topic = wqTopicService.getById(topicIdList[0]);
		}else{
			throw new ServiceException("至少选择一个话题");
		}
		
    	wqDynamic.setUserId(user.getUserId());
    	wqDynamic.setAvatar(user.getAvatar());
    	wqDynamic.setNickName(user.getNickName());
    	wqDynamic.setSex(user.getSex());
    	
    	Address address = AddressUtils.getAddressByIP();
    	wqDynamic.setLon(address.getLng());
    	wqDynamic.setLat(address.getLat());
    	wqDynamic.setCity(address.getCity());
    	wqDynamic.setAge(user.getAge());
    	wqDynamic.setOfficial(user.getOfficial());
    	wqDynamic.setIsPay(user.getIsPay());
    	wqDynamic.setIdCardStatus(user.getIdCardStatus());
    	wqDynamic.setPayNum(user.getPayNum());
    	wqDynamic.setStatus(user.getIsBlack());
    	String message = wqDynamic.getMessage();
    	if(StringUtils.getMatch(message) || user.getAge() < 17){
    		throw new ServiceException("请文明交友，多次警告会被关进小黑屋哦");
    	}
    	
    	if(user.getAge() < 18){
    		throw new ServiceException("未成年禁止使用", 520);
    	}
    	
    	// 只有女生加广告
    	if("1".equals(user.getSex())){
    		WxMaForm wxMaForm = new WxMaForm();
        	wxMaForm.setAppId(user.getAppId());
        	wxMaForm.setUrl(wqDynamic.getImage());
        	String imageLock = wxMaCodeService.getQrCode(wxMaForm);
        	wqDynamic.setImageLock(imageLock);
    	}
    	
    	wqDynamicService.save(wqDynamic);
    	
    	// 统计动态总数
    	Integer dynamicNum = wqDynamicService.getNumByUserId(wqDynamic.getUserId());
    	user.setDynamicNum(dynamicNum);
    	sysUserService.updateById(user);
    	
    	if(StringUtils.isNotBlank(topicIds)){
    		String[] topicIdList = topicIds.split(",");
    		for(String topicId : topicIdList){
    			WqDynamicTopic dynamicTopic = new WqDynamicTopic();
    			dynamicTopic.setDynamicId(wqDynamic.getId());
    			dynamicTopic.setTopicId(topicId);
    			dynamicTopic.setTitle(topic.getTitle());
    			wqDynamicTopicService.save(dynamicTopic);
    		}
    	}
    	
    	// 给管理发送审核地址
    	threadPoolTaskExecutor.execute(() -> {
            try {
            	List<SysUser> userList = sysUserService.getManagerList();
            	for(SysUser u : userList){
            		WxMaMsgForm form = new WxMaMsgForm();
            		form.setAppId(u.getAppId());
            		form.setOpenId(u.getOpenId());
            		Map<String,String> map = new HashMap<>();
            		map.put("phrase1", "待审通知");
            		map.put("date2", DateUtil.now());
            		map.put("name3", "管理员");
            		map.put("thing4", "您好，有新的帖子待审核");
            		form.setDataMap(map);
            		form.setPage("packgeMine/pages/index/dynamic?dynamicId="+wqDynamic.getId());
            		boolean flag = wxMsgService.sendSubscribeMsg(form);
            		if(!flag){
            			WxMpMsgForm msgForm = new WxMpMsgForm();
                		msgForm.setWxId(u.getWxId());
                		msgForm.setAppId(u.getAppId());
                		msgForm.setOpenId(u.getWxOpenId());
                		Map<String,String> dataMap = new HashMap<>();
                		dataMap.put("first", "待审通知");
                		dataMap.put("keyword1", "管理员");
                		dataMap.put("keyword2", DateUtil.now());
                		dataMap.put("keyword3", "您好，有新的帖子待审核");
                		dataMap.put("remark", "本条信息是站内信通知，祝您早日脱单！点击查看详情");
                		msgForm.setDataMap(dataMap);
                		msgForm.setPage("packgeMine/pages/index/dynamic?dynamicId="+wqDynamic.getId());
                		wxMsgService.sendTemplateMsg(msgForm);
            		}
            	}
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    	
    	return true;
	}

	public synchronized Integer saveVipDynamic(WqDynamic wqDynamic) {
		String topicIds = wqDynamic.getTopicIds();
		SysUser user = sysUserService.getById(wqDynamic.getUserId());
		Integer publishNum = user.getPublishNum();
		
		WqTopic topic = null;
		if(StringUtils.isNotBlank(topicIds)){
			String[] topicIdList = topicIds.split(",");
			if(topicIdList.length > 1){
				throw new ServiceException("最多只能选择一个话题");
			}
			
			topic = wqTopicService.getById(topicIdList[0]);
			
			if(publishNum < 1){
				throw new ServiceException("今日次数已用完");
			}
		}else{
			throw new ServiceException("至少选择一个话题");
		}
		
		Address address = AddressUtils.getAddressByIP();
    	wqDynamic.setUserId(user.getUserId());
    	wqDynamic.setAvatar(user.getAvatar());
    	wqDynamic.setNickName(user.getNickName());
    	wqDynamic.setSex(user.getSex());
    	wqDynamic.setLon(address.getLng());
    	wqDynamic.setLat(address.getLat());
    	wqDynamic.setCity(address.getCity());
    	wqDynamic.setAge(user.getAge());
    	wqDynamic.setOfficial(user.getOfficial());
    	wqDynamic.setIsPay(user.getIsPay());
    	wqDynamic.setIdCardStatus(user.getIdCardStatus());
    	wqDynamic.setPayNum(user.getPayNum());
    	wqDynamic.setStatus(user.getIsBlack());
    	String message = wqDynamic.getMessage();
    	if(StringUtils.getMatch(message) || user.getAge() < 17){
    		//throw new ServiceException("请文明交友，多次警告会被关进小黑屋哦");
    		wqDynamic.setStatus("1");
    		user.setIsBlack("1");
    	}
    	
    	// 酒吧
    	if("wx62d4213d83c6e5b2".equals(user.getAppId())){
    		wqDynamic.setStatus("3");
    		wqDynamic.setIsAuth("5");
    	}
    	
    	
    	// 只有女生加广告
    	if("1".equals(user.getSex())){
    		WxMaForm wxMaForm = new WxMaForm();
        	wxMaForm.setAppId(user.getAppId());
        	wxMaForm.setUrl(wqDynamic.getImage());
        	String imageLock = wxMaCodeService.getQrCode(wxMaForm);
        	wqDynamic.setImageLock(imageLock);
    	}
    	
    	wqDynamic.setDelFlag("1");
    	wqDynamicService.save(wqDynamic);
    	
    	// 统计动态总数
    	Integer dynamicNum = wqDynamicService.getNumByUserId(wqDynamic.getUserId());
    	user.setDynamicNum(dynamicNum);
    	publishNum = publishNum-1;
    	user.setPublishNum(publishNum);
    	sysUserService.updateById(user);
    	
    	if(StringUtils.isNotBlank(topicIds)){
    		String[] topicIdList = topicIds.split(",");
    		for(String topicId : topicIdList){
    			WqDynamicTopic dynamicTopic = new WqDynamicTopic();
    			dynamicTopic.setDynamicId(wqDynamic.getId());
    			dynamicTopic.setTopicId(topicId);
    			dynamicTopic.setTitle(topic.getTitle());
    			wqDynamicTopicService.save(dynamicTopic);
    		}
    	}
    	
    	// 给管理发送审核地址
    	threadPoolTaskExecutor.execute(() -> {
            try {
            	List<SysUser> userList = sysUserService.getManagerList();
            	for(SysUser u : userList){
            		WxMaMsgForm form = new WxMaMsgForm();
            		form.setAppId(u.getAppId());
            		form.setOpenId(u.getOpenId());
            		Map<String,String> map = new HashMap<>();
            		map.put("phrase1", "待审通知");
            		map.put("date2", DateUtil.now());
            		map.put("name3", "管理员");
            		map.put("thing4", "您好，有新的帖子待审核");
            		form.setDataMap(map);
            		form.setPage("packgeMine/pages/index/dynamic?dynamicId="+wqDynamic.getId());
            		boolean flag = wxMsgService.sendSubscribeMsg(form);
            		if(!flag){
            			WxMpMsgForm msgForm = new WxMpMsgForm();
                		msgForm.setWxId(u.getWxId());
                		msgForm.setAppId(u.getAppId());
                		msgForm.setOpenId(u.getWxOpenId());
                		Map<String,String> dataMap = new HashMap<>();
                		dataMap.put("first", "待审通知");
                		dataMap.put("keyword1", "管理员");
                		dataMap.put("keyword2", DateUtil.now());
                		dataMap.put("keyword3", "您好，有新的帖子待审核");
                		dataMap.put("remark", "本条信息是站内信通知，祝您早日脱单！点击查看详情");
                		msgForm.setDataMap(dataMap);
                		msgForm.setPage("packgeMine/pages/index/dynamic?dynamicId="+wqDynamic.getId());
                		wxMsgService.sendTemplateMsg(msgForm);
            		}
            	}
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    	
    	return publishNum;
	}

	public synchronized Boolean addParty(WqDynamic wqDynamic) {
		WqDynamic dynamic = wqDynamicService.getById(wqDynamic.getId());
		if(dynamic.getPartyNum() > 0){
			Integer partyNum = dynamic.getPartyNum();
			// 抢红包
			PayCoinUserForm payCoinUserForm = new PayCoinUserForm();
			payCoinUserForm.setUserId(wqDynamic.getUserId());
			payCoinUserForm.setCoinNum(dynamic.getPartyCoin());
			payCoinUserForm.setCoinType("0");
			payCoinUserForm.setSourceId(wqDynamic.getId());
			payCoinUserForm.setRemark("抢红包");
			payCoinUserService.savePartyPayCoinUser(payCoinUserForm);
			
			partyNum = partyNum - 1;
			dynamic.setPartyNum(partyNum);
			wqDynamicService.updateById(dynamic);
			
			// 评论
			WqComment comment = new WqComment();
			comment.setDynamicId(dynamic.getId());
			comment.setContent("我抢到了"+dynamic.getPartyCoin()+"趣豆，谢谢老板");
			wqCommentService.insertWqComment(comment);
		}else{
			throw new ServiceException("红包已被抢光");
		}
		return true;
	}

	public synchronized Boolean addPartyDynamic(WqDynamic wqDynamic) {
		// 防止重复发布
		if(StringUtils.isNotBlank(wqDynamic.getUid())){
			QueryWrapper<WqDynamic> queryWrapper = new QueryWrapper<>();
			WqDynamic entity = new WqDynamic();
			entity.setUid(wqDynamic.getUid());
			queryWrapper.setEntity(entity);
			Integer count = wqDynamicService.count(queryWrapper);
			if(count > 0){
				return true;
			}
		}
		
		if(wqDynamic.getPartyAccount() < 400){
			throw new ServiceException("参数异常");
		}
		Integer partyNum = wqDynamic.getPartyAccount() / wqDynamic.getPartyCoin();
		if(!partyNum.equals(wqDynamic.getPartyNum())){
			throw new ServiceException("参数异常");
		}
		
		SysUser user = sysUserService.getById(wqDynamic.getUserId());
		if(StringUtils.isBlank(user.getSex())){
			throw new ServiceException("请在个人主页完善性别信息");
		}
		
		Integer amount = payCoinUserService.getAmount();
		if(wqDynamic.getPartyAccount() > amount){
			// 趣豆不足
			throw new ServiceException("发布红包需要【"+wqDynamic.getPartyAccount()+"】趣豆，请充值",888);
		}
		
		Address address = AddressUtils.getAddressByIP();
    	wqDynamic.setUserId(user.getUserId());
    	wqDynamic.setAvatar(user.getAvatar());
    	wqDynamic.setNickName(user.getNickName());
    	wqDynamic.setSex(user.getSex());
    	wqDynamic.setLon(address.getLng());
    	wqDynamic.setLat(address.getLat());
    	wqDynamic.setCity(address.getCity());
    	wqDynamic.setAge(user.getAge());
    	wqDynamic.setStatus(user.getIsBlack());
    	wqDynamic.setIsParty("1");
    	String message = wqDynamic.getMessage();
    	if(StringUtils.getMatch(message)){
    		throw new ServiceException("请文明交友，多次警告会被关进小黑屋哦");
    	}
    	wqDynamicService.save(wqDynamic);
    	
    	// 统计动态总数
    	Integer dynamicNum = wqDynamicService.getNumByUserId(wqDynamic.getUserId());
    	user.setDynamicNum(dynamicNum);
    	sysUserService.updateById(user);
    	
    	PayCoinUserForm payCoinUserForm = new PayCoinUserForm();
		payCoinUserForm.setUserId(wqDynamic.getUserId());
		payCoinUserForm.setCoinNum(wqDynamic.getPartyAccount());
		payCoinUserForm.setCoinType("1");
		payCoinUserForm.setSourceId(wqDynamic.getId());
		payCoinUserForm.setRemark("发布红包消费");
		payCoinUserService.savePayCoinUser(payCoinUserForm);
    	return true;
	}

	public synchronized Integer addVipDynamic(WqDynamic wqDynamic) {
		String topicIds = wqDynamic.getTopicIds();
		SysUser user = sysUserService.getById(wqDynamic.getUserId());
		
		if(user.getVipEndTime() == null || user.getVipEndTime().compareTo(new Date()) < 0){
			throw new ServiceException("新用户体验会员已过期，请开通会员",788);
		}
		
		Integer publishNum = user.getPublishNum();
		
		WqTopic topic = null;
		if(StringUtils.isNotBlank(topicIds)){
			String[] topicIdList = topicIds.split(",");
			if(topicIdList.length > 1){
				throw new ServiceException("最多只能选择一个话题");
			}
			
			topic = wqTopicService.getById(topicIdList[0]);
			
			if(publishNum < 1){
				throw new ServiceException("今日次数已用完");
			}
		}else{
			throw new ServiceException("至少选择一个话题");
		}
		
		Address address = AddressUtils.getAddressByIP();
    	wqDynamic.setUserId(user.getUserId());
    	wqDynamic.setAvatar(user.getAvatar());
    	wqDynamic.setNickName(user.getNickName());
    	wqDynamic.setSex(user.getSex());
    	wqDynamic.setLon(address.getLng());
    	wqDynamic.setLat(address.getLat());
    	wqDynamic.setCity(address.getCity());
    	wqDynamic.setAge(user.getAge());
    	wqDynamic.setStatus(user.getIsBlack());
    	wqDynamic.setStatus("1");
    	
    	String message = wqDynamic.getMessage();
    	if(StringUtils.getMatch(message)){
    		throw new ServiceException("请文明交友，多次警告会被关进小黑屋哦");
    	}
    	
    	// 只有女生加广告
    	if("1".equals(user.getSex())){
    		WxMaForm wxMaForm = new WxMaForm();
        	wxMaForm.setAppId(user.getAppId());
        	wxMaForm.setUrl(wqDynamic.getImage());
        	String imageLock = wxMaCodeService.getQrCode(wxMaForm);
        	wqDynamic.setImageLock(imageLock);
    	}
    	
    	wqDynamicService.save(wqDynamic);
    	
    	// 统计动态总数
    	Integer dynamicNum = wqDynamicService.getNumByUserId(wqDynamic.getUserId());
    	user.setDynamicNum(dynamicNum);
    	publishNum = publishNum-1;
    	user.setPublishNum(publishNum);
    	sysUserService.updateById(user);
    	
    	if(StringUtils.isNotBlank(topicIds)){
    		String[] topicIdList = topicIds.split(",");
    		for(String topicId : topicIdList){
    			WqDynamicTopic dynamicTopic = new WqDynamicTopic();
    			dynamicTopic.setDynamicId(wqDynamic.getId());
    			dynamicTopic.setTopicId(topicId);
    			dynamicTopic.setTitle(topic.getTitle());
    			wqDynamicTopicService.save(dynamicTopic);
    		}
    	}
    	
    	return publishNum;
	}

	public void passById(String id) {
		SysUser user = sysUserService.getById(SecurityUtils.getUserId());
		if("1".equals(user.getIsManager())){
			WqDynamic dynamic = wqDynamicService.getById(id);
			dynamic.setDelFlag("0");
			dynamic.setStatus("0");
			wqDynamicService.updateById(dynamic);
			
			SysUser sysUser = sysUserService.getById(dynamic.getUserId());
			
			// 发送微信订阅消息
			WxMaMsgForm form = new WxMaMsgForm();
			form.setAppId(sysUser.getAppId());
			form.setOpenId(sysUser.getOpenId());
			Map<String,String> map = new HashMap<>();
			map.put("phrase1", "审核通知");
			map.put("date2", DateUtil.now());
			map.put("name3", "管理员");
			map.put("thing4", "您好，您的帖子已审核通过");
			form.setDataMap(map);
			form.setPage("pages/index?index=1");
			boolean flag = wxMsgService.sendSubscribeMsg(form);
			if(!flag){
				WxMpMsgForm msgForm = new WxMpMsgForm();
	    		msgForm.setWxId(sysUser.getWxId());
	    		msgForm.setAppId(sysUser.getAppId());
	    		msgForm.setOpenId(sysUser.getWxOpenId());
	    		Map<String,String> dataMap = new HashMap<>();
	    		dataMap.put("first", "审核通知");
	    		dataMap.put("keyword1", "管理员");
	    		dataMap.put("keyword2", DateUtil.now());
	    		dataMap.put("keyword3", "您好，您的帖子已审核通过");
	    		dataMap.put("remark", "本条信息是站内信通知，祝您早日脱单！点击查看详情");
	    		msgForm.setDataMap(dataMap);
	    		msgForm.setPage("pages/index?index=1");
	    		wxMsgService.sendTemplateMsg(msgForm);
			}
			
		}
	}

	public void rejectById(String id) {
		SysUser user = sysUserService.getById(SecurityUtils.getUserId());
		if("1".equals(user.getIsManager())){
			WqDynamic dynamic = wqDynamicService.getById(id);
			dynamic.setDelFlag("1");
			dynamic.setStatus("1");
			wqDynamicService.updateById(dynamic);
			
			SysUser sysUser = sysUserService.getById(dynamic.getUserId());
			sysUser.setIsBlack("1");
			sysUserService.updateById(sysUser);
			
			// 发送微信订阅消息
			WxMaMsgForm form = new WxMaMsgForm();
			form.setAppId(sysUser.getAppId());
			form.setOpenId(sysUser.getOpenId());
			Map<String,String> map = new HashMap<>();
			map.put("phrase1", "审核通知");
			map.put("date2", DateUtil.now());
			map.put("name3", "管理员");
			map.put("thing4", "您好，您的帖子已被删除");
			form.setDataMap(map);
			form.setPage("pages/index?index=1");
			boolean flag = wxMsgService.sendSubscribeMsg(form);
			if(!flag){
				WxMpMsgForm msgForm = new WxMpMsgForm();
	    		msgForm.setWxId(sysUser.getWxId());
	    		msgForm.setAppId(sysUser.getAppId());
	    		msgForm.setOpenId(sysUser.getWxOpenId());
	    		Map<String,String> dataMap = new HashMap<>();
	    		dataMap.put("first", "审核通知");
	    		dataMap.put("keyword1", "管理员");
	    		dataMap.put("keyword2", DateUtil.now());
	    		dataMap.put("keyword3", "您好，您的帖子已被删除");
	    		dataMap.put("remark", "本条信息是站内信通知，祝您早日脱单！点击查看详情");
	    		msgForm.setDataMap(dataMap);
	    		msgForm.setPage("pages/index?index=1");
	    		wxMsgService.sendTemplateMsg(msgForm);
			}
			
		}
	}

	public void editUser(String id) {
		SysUser user = sysUserService.getById(SecurityUtils.getUserId());
		if("1".equals(user.getIsManager())){
			WqDynamic dynamic = wqDynamicService.getById(id);
			Long userId = dynamic.getUserId();
			SysUser sysUser = sysUserService.getById(userId);
			
			sysUser.setIsBlack("1");
			sysUser.setNickName("资料不通过，已被重置");
			sysUser.setSignName("资料不通过，已被重置");
			sysUser.setIntroduce("资料不通过，已被重置");
			sysUser.setProfession("资料不通过，已被重置");
			sysUser.setAvatar("http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20240318/f14bc5cace004d0d8f202a3575721c6e.jpg");
			sysUser.setAlbums("http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20240318/f14bc5cace004d0d8f202a3575721c6e.jpg");
			sysUser.setHobby("资料不通过，已被重置");
			sysUser.setIsWelcome(0);
			sysUserService.updateById(sysUser);
			
			// 发送微信订阅消息
			WxMaMsgForm form = new WxMaMsgForm();
			form.setAppId(sysUser.getAppId());
			form.setOpenId(sysUser.getOpenId());
			Map<String,String> map = new HashMap<>();
			map.put("phrase1", "审核通知");
			map.put("date2", DateUtil.now());
			map.put("name3", "管理员");
			map.put("thing4", "您好，您的资料已被重置");
			form.setDataMap(map);
			form.setPage("pages/index?index=4");
			boolean flag = wxMsgService.sendSubscribeMsg(form);
			if(!flag){
				WxMpMsgForm msgForm = new WxMpMsgForm();
	    		msgForm.setWxId(sysUser.getWxId());
	    		msgForm.setAppId(sysUser.getAppId());
	    		msgForm.setOpenId(sysUser.getWxOpenId());
	    		Map<String,String> dataMap = new HashMap<>();
	    		dataMap.put("first", "审核通知");
	    		dataMap.put("keyword1", "管理员");
	    		dataMap.put("keyword2", DateUtil.now());
	    		dataMap.put("keyword3", "您好，您的资料已被重置");
	    		dataMap.put("remark", "本条信息是站内信通知，祝您早日脱单！点击查看详情");
	    		msgForm.setDataMap(dataMap);
	    		msgForm.setPage("pages/index?index=4");
	    		wxMsgService.sendTemplateMsg(msgForm);
			}
		}
	}
	
}
